<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateCruiseCheckAgainstTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cruise_check_against', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->default(0);
            $table->unsignedInteger('cruiseCheckDetailId')->default(0)->comment('巡检报告id');
            $table->tinyInteger('businessType')->default(0)->comment('业务类型 1后台手动添加（没有关联） 2异常报备 3整改违约');
            $table->unsignedInteger('businessId')->default(0)->comment('关联业务表id 1:0 2:异常报备id 3巡检报告id');
            $table->string('serialNum', 32)->default('')->comment('违约函编号');
            $table->char('version', 16)->default('')->comment('违约函版本 demo:v1.1');
            $table->unsignedInteger('price')->default(0)->comment('应付违约金额');
            $table->unsignedInteger('paidPrice')->default(0)->comment('已支付金额');
            $table->unsignedInteger('payTime')->default(0)->comment('支付成功时间');
            $table->unsignedInteger('endTime')->default(0)->comment('截止处理时间');
            $table->tinyInteger('level')->default(0)->comment('违约级别 0默认 1警告 2处罚');
            $table->tinyInteger('status')->default(0)->comment('0未处理 1已处理 2已关闭');
            $table->tinyInteger('type')->default(0)->comment('违约分类 0-默认 1-自采管理 2-门店QSC\运营管理');
            $table->tinyInteger('templateType')->default(0)->comment('违约函模板类型 0常规模板 1超时模板');
            $table->string('behaviorDesc', 255)->default('')->comment('违约行为描述');
            $table->string('rectifyPlan', 255)->default('')->comment('整改措施');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '稽核 - 违约函';

            $table->index('shopId', 'idx_shopId');
            $table->index('cruiseCheckDetailId', 'idx_cruiseCheckDetailId');
            $table->index('endTime', 'idx_endTime');
            $table->index(['businessType', 'businessId'], 'idx_business');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cruise_check_against');
    }
}
